<?php


namespace app\common\model\mysql;


use think\Model;

class User extends Model
{
    /**
     * 通过手机号获取用户信息
     * @param $phoneNumber
     * @return array|bool
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\DbException
     * @throws \think\db\exception\ModelNotFoundException
     */
    public function getUserByPhoneNumber($phoneNumber) {
        if (!$phoneNumber) {
            return false;
        }
        $res = $this->where('phone_number', $phoneNumber)->find();
        return $res;
    }

    /**
     * 通过ID获取用户信息
     * @param $id
     * @return array|bool|Model|null
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\DbException
     * @throws \think\db\exception\ModelNotFoundException
     */
    public function getUserById($id){
        if (!$id) {
            return false;
        }
        $res = $this->where('id', $id)->find();
        return $res;
    }
}